Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use id entity attribute when setting exampleOfWork property #19396

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

nsoranzo
Copy link
Member

@nsoranzo nsoranzo commented Jan 10, 2025

Fix the following error in 3 unit tests when using rocrate 0.13.0 (e.g. in test_galaxy_packages tests run on Python 3.13):

______________________ test_export_invocation_to_ro_crate ______________________

tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-5/test_export_invocation_to_ro_c0')

    def test_export_invocation_to_ro_crate(tmp_path):
        app = _mock_app()
        workflow_invocation = _setup_invocation(app)
        crate_directory = tmp_path / "crate"
        with store.ROCrateModelExportStore(crate_directory, app=app) as export_store:
            export_store.export_workflow_invocation(workflow_invocation)
>       validate_invocation_crate_directory(crate_directory)

tests/data/model/test_model_store.py:627:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/data/model/test_model_store.py:564: in validate_invocation_crate_directory
    validate_create_action(crate)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

ro_crate = <rocrate.rocrate.ROCrate object at 0x7fb4673c2520>

    def validate_create_action(ro_crate: ROCrate):
        workflow = ro_crate.mainEntity
        actions = [_ for _ in ro_crate.contextual_entities if "CreateAction" in _.type]
        assert len(actions) == 1
        wf_action = actions[0]
        assert wf_action["instrument"]
        assert wf_action["instrument"] is workflow
        wf_objects = wf_action["object"]
        wf_results = wf_action["result"]
        assert len(wf_objects) == 1
        assert len(wf_results) == 1
        for entity in wf_results:
            if entity.id.endswith(".txt"):
                assert "File" in entity.type
                wf_output_file = entity
                assert wf_output_file["encodingFormat"] == "text/plain"
>               assert wf_output_file["exampleOfWork"] is workflow["output"][0]
E               AssertionError: assert '#d2ed04ef-36f8-49ae-86ce-47cb03a856c0' is <d2ed04ef-36f8-49ae-86ce-47cb03a856c0 FormalParameter>

tests/data/model/test_model_store.py:540: AssertionError

Also:

  • Remove _add_step_tool_pv method, unused since commit 01782c0 .
  • Uniform use of tmp_path in ro-crate tests.

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

Fix the following error in 3 unit tests when using rocrate 0.13.0 :

```
______________________ test_export_invocation_to_ro_crate ______________________

tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-5/test_export_invocation_to_ro_c0')

    def test_export_invocation_to_ro_crate(tmp_path):
        app = _mock_app()
        workflow_invocation = _setup_invocation(app)
        crate_directory = tmp_path / "crate"
        with store.ROCrateModelExportStore(crate_directory, app=app) as export_store:
            export_store.export_workflow_invocation(workflow_invocation)
>       validate_invocation_crate_directory(crate_directory)

tests/data/model/test_model_store.py:627:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/data/model/test_model_store.py:564: in validate_invocation_crate_directory
    validate_create_action(crate)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

ro_crate = <rocrate.rocrate.ROCrate object at 0x7fb4673c2520>

    def validate_create_action(ro_crate: ROCrate):
        workflow = ro_crate.mainEntity
        actions = [_ for _ in ro_crate.contextual_entities if "CreateAction" in _.type]
        assert len(actions) == 1
        wf_action = actions[0]
        assert wf_action["instrument"]
        assert wf_action["instrument"] is workflow
        wf_objects = wf_action["object"]
        wf_results = wf_action["result"]
        assert len(wf_objects) == 1
        assert len(wf_results) == 1
        for entity in wf_results:
            if entity.id.endswith(".txt"):
                assert "File" in entity.type
                wf_output_file = entity
                assert wf_output_file["encodingFormat"] == "text/plain"
>               assert wf_output_file["exampleOfWork"] is workflow["output"][0]
E               AssertionError: assert '#d2ed04ef-36f8-49ae-86ce-47cb03a856c0' is <d2ed04ef-36f8-49ae-86ce-47cb03a856c0 FormalParameter>

tests/data/model/test_model_store.py:540: AssertionError
```

Also:
- Remove unused `_add_step_tool_pv` method.
@github-actions github-actions bot added area/testing area/database Galaxy's database or data access layer labels Jan 10, 2025
@github-actions github-actions bot added this to the 25.0 milestone Jan 10, 2025
@nsoranzo nsoranzo requested a review from a team January 10, 2025 18:21
@nsoranzo
Copy link
Member Author

Test failures unrelated.

Copy link
Contributor

@davelopez davelopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! It looks good to me.

@nsoranzo nsoranzo merged commit 0858e07 into galaxyproject:dev Jan 13, 2025
56 of 59 checks passed
@nsoranzo nsoranzo deleted the ro_crate branch January 13, 2025 11:55
@nsoranzo
Copy link
Member Author

If we'd like to have the test_galaxy_packages tests pass on 24.2, we can backport just the second commit, let me know!

@davelopez
Copy link
Contributor

Sounds like a good idea :) 👍

jdavcs added a commit that referenced this pull request Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/database Galaxy's database or data access layer area/testing kind/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants